//
//  YYSRecomandCell.m
//  FanLaiWu
//
//  Created by gonglei on 17/3/16.
//  Copyright © 2017年 yys. All rights reserved.
//

#import "YYSRecomandCell.h"
#import "YYSNewsVideoCell.h"
#import "YYSPlayVideoController.h"
@interface YYSRecomandCell ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;

@end

@implementation YYSRecomandCell
static NSString *ID = @"YYSNewsVideoCell";
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    
    
    
    layout.itemSize = CGSizeMake(([UIScreen mainScreen].bounds.size.width)/2  , 160);
   
    layout.minimumLineSpacing = 0;
    layout.minimumInteritemSpacing = 0;
    layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
//    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.collectionView.collectionViewLayout = layout;
    //    self.collectionView.showsHorizontalScrollIndicator = NO;
    self.collectionView.showsVerticalScrollIndicator = NO;
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1];
    // 注册
    [self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([YYSNewsVideoCell class]) bundle:nil] forCellWithReuseIdentifier:ID];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}
#pragma mark - <UICollectionViewDelegate,UICollectionViewDataSource>
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.model.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    YYSNewsVideoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
    cell.model = self.model[indexPath.row];
    cell.type = self.type;
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    YYSPlayVideoController *play = [[YYSPlayVideoController alloc] init];
    play.ID = self.model[indexPath.row][@"id"];
    [self.viewController.view.superview.viewController.navigationController pushViewController:play animated:YES];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
